package com.chanyachting.emall.action.applicationLeter;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.chanyachting.emall.domain.Educationhistory;
import com.chanyachting.emall.form.EducationhistoryForm;
import com.chanyachting.emall.service.ApplicationLeterService;
import com.chanyachting.emall.serviceImpl.ApplicationLeterServiceImpl;
import com.chanyachting.emall.util.RequestUtil;

public class DelEducationHistoryAction extends Action {

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		RequestUtil ru=new RequestUtil(request);
		
		EducationhistoryForm ehForm=(EducationhistoryForm)form;
		
		Educationhistory eh=new Educationhistory();
		
		BeanUtils.copyProperties(eh, ehForm);
		
		int ehId=Integer.parseInt(ru.getParameter("id","0"));
		
		int appId=Integer.parseInt(ru.getParameter("appId","0"));
		
		if(appId!=0){
			
			ApplicationLeterService alservice=new ApplicationLeterServiceImpl();
			
			alservice.delEducationhistory(eh);
			
		}else{
			
			//删除保存在session中的工作经历
			List ehList=(List)ru.getSessionObject(ApplicationLeterService.EDUCATIONHISTORYLISTINSESSINO, new ArrayList());
			
			ehList.remove(ehId);
			
		}

		return mapping.findForward("");
	}
	
	
	
	

}
